# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Lev Lybin <lev.lybin@gmail.com>
# Contributor: lagrange <flkazemakase@gmail.com>
# Contributor: mid-kid <esteve.varela@gmail.com>

pkgname=python-kivy
pkgver=2.1.0
pkgrel=2
pkgdesc="A software library for rapid development of hardware-accelerated multitouch applications."
arch=('loong64' 'x86_64')
url="https://kivy.org/"
license=('MIT')
depends=('python-docutils' 'gstreamer' 'sdl2_ttf' 'sdl2_mixer' 'sdl2_image')
makedepends=('python-setuptools' 'cython')
optdepends=('python-oscpy: for TUIO provider')
checkdepends=('python-pytest' 'python-pytest-benchmark' 'python-coverage' 'python-gobject' 'xorg-server-xvfb' 'opencv' 'python-pyenchant'
              'git' 'mtdev' 'xclip' 'xsel' 'gtk3' 'gst-plugins-base'
              'gst-plugins-good' 'gst-libav' 'dbus-python')
source=("https://pypi.io/packages/source/K/Kivy/Kivy-$pkgver.tar.gz")
sha512sums=('934d209558629114e81af038320d4b090924b192226786da6a6664e7073e47e9c0d8b83c4ac437422759c8c477d71241e5ca180766b6018944b7c2e115c50ccf')

export LC_CTYPE=en_US.UTF-8

prepare() {
  cd Kivy-$pkgver
  # Do not use certifi
  sed -i '/import certifi/d;s|certifi.where()|"/etc/ssl/certs/ca-certificates.crt"|' kivy/tests/test_urlrequest.py
}

build() {
  cd Kivy-$pkgver
  python setup.py build
}

check() {
  cd Kivy-$pkgver
  python setup.py build_ext --inplace
  xvfb-run -s "-screen 0 1280x720x24 -ac +extension GLX" pytest kivy/tests
}

package() {
  cd Kivy-$pkgver
  python setup.py install --prefix=/usr --root="$pkgdir"
  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
